<template>
  <a-modal
    :title="title"
    :width="800"
    :visible="visible"
    :confirmLoading="confirmLoading"
    @ok="handleOk"
    @cancel="handleCancel"
    :footer="null"
    cancelText="关闭">

    <table id="table_report" class="table table-striped table-bordered table-hover">

           			<tr>
           				<td style="width:90px;text-align: right;padding-top: 80px;">基本信息:</td>
           				<td>
           					<p style="float: left;">


                      车牌号：<span id="plateNo" >
           {{result.plateNo }}
                    </span><br>



             停车场名称：<span id="parkName" >
           {{result.parkName }}
                    </span><br>


             停车场出口名称：<span id="armName" >
           {{result.armName }}
                    </span><br>


             车辆类型：<span id="carType"  v-text="CarType(result.carType)">
                      {{result.carType }}
                    </span><br>


             入场时间：<span id="enterTime" >
           {{result.enterTime }}
                    </span><br>

             停车时长：<span id="elapsedTime" v-text="chargeDuration(result.elapsedTime)">
                    </span><br>


             总费用: <span id="totalFee" v-text="chargeTotalFee(result.totalFee)" >
                    </span><br>


             已支付费用: <span id="payedFee" v-text="chargeTotalFee(result.payedFee)" >
                    </span><br>


             未付金额: <span id="unpayFee" v-text="chargeTotalFee(result.unpayFee)"  >
                    </span><br>


             收费后允许延时出场的时间限制（分钟），默认：20分钟：<span id="delayTime" >
           {{result.delayTime }}
                    </span><br>

  创建时间：<span id="createTime" >
           {{result.createTime }}
                    </span><br>
  停车入场图片URL：<span id="imgPath" >
                       <img style="max-width:35px;max-height:35px;min-height:20px;min-width:20px;text-align:center;cursor:pointer;border:1px #BFBFBF solid;padding: 2px 2px 2px 2px;background-color:white;"
                         v-if="result.imgPath != null"  preview :src="result.imgPath"  />
                 </span><br>
	</p>
			</td>
                			</tr>



                			<tr>
                				<td style="text-align: center;" colspan="10">
                                 <a-button type="primary" @click="close">关闭</a-button>
                				</td>
                			</tr>
                		</table>

  </a-modal>
</template>

<script>
  import { httpAction } from '@/api/manage'
  import pick from 'lodash.pick'
  import moment from "moment"

  export default {
    name: "ParkgetcarfeelogModal",
    data () {
      return {
        title:"操作",
        visible: false,
        model: {},
        labelCol: {
          xs: { span: 24 },
          sm: { span: 5 },
        },
        wrapperCol: {
          xs: { span: 24 },
          sm: { span: 16 },
        },
         result: {

                },
        confirmLoading: false,
        form: this.$form.createForm(this),
        validatorRules:{
        },
        url: {
          add: "/order/parkgetcarfeelog/add",
          edit: "/order/parkgetcarfeelog/edit",
        },
      }
    },
    created () {
    },
    methods: {
      add () {
        this.edit({});
      },
      edit (record) {
             Object.assign(this.result, record);
              this.visible = true;
            },
      close () {
        this.$emit('close');
        this.visible = false;
      },
      handleOk () {
        const that = this;
        // 触发表单验证
        this.form.validateFields((err, values) => {
          if (!err) {
            that.confirmLoading = true;
            let httpurl = '';
            let method = '';
            if(!this.model.id){
              httpurl+=this.url.add;
              method = 'post';
            }else{
              httpurl+=this.url.edit;
               method = 'put';
            }
            let formData = Object.assign(this.model, values);
            //时间格式化

            httpAction(httpurl,formData,method).then((res)=>{
              if(res.success){
                that.$message.success(res.message);
                that.$emit('ok');
              }else{
                that.$message.warning(res.message);
              }
            }).finally(() => {
              that.confirmLoading = false;
              that.close();
            })



          }
        })
      },
      handleCancel () {
        this.close()
      },
      //显示0无牌车，1有牌车
      CarType(t) {
        if (t ==0) {
          return "无牌车"
        } else if (t ==1) {
          return "有牌车"
        }else{
          return "不清楚"
        }
      },
      chargeTotalFee(t){
        var rmb = parseFloat(t/100);
        return rmb+"元";
      },
      //停车时长
      chargeDuration(t){
        let hr = parseInt(t / 60)
        let min = parseInt(t % 60)
        return hr+'小时'+min+"分";
      }

    }
  }

</script>

<style lang="less" scoped>

</style>